<?php
ob_start();
session_start(); //Initialize php-session

$generation_time = microtime( true ); //Start page generation time timer

date_default_timezone_set('Europe/Berlin');

/*****************************************************************
 * Fusion.Board
 *
 * @author                Denis Wrobel
 * @license               http://www.gnu.org/licenses/gpl-3.0.html
 * @version               0.1
 *
 *****************************************************************/

//error_reporting( 0 ); //Turn off error reporting by php parser


########################## PHP ENVIRONMENT ##########################
define( 'IN_SCRIPT', true ); //Define that we are in script
define( 'ROOT'     , './' ); //Root directory

require_once( ROOT . 'constants.php' );
require_once( KERNEL . 'Config.php' );


if( strpos( 'ApacheBench', $_SERVER['USER_AGENT'] ) !== false && BLOCK_AB )
{
    die('ApacheBench is blocked');
}
#####################################################################


########################## CLASSES ##########################
require_once( CLASSES . 'template.Class.php' );
require_once( CLASSES . 'mysql.Class.php' );
require_once( CLASSES . 'error.Class.php' );
require_once( CLASSES . 'cache.Class.php' );
require_once( CLASSES . 'user.Class.php' );
require_once( CLASSES . 'language.Class.php' );
require_once( CLASSES . 'page.Class.php' );
require_once( CLASSES . 'plugin.Class.php' );
require_once( CLASSES . 'core.Class.php' );
require_once( CLASSES . 'forum.Class.php' );
require_once( CLASSES . 'recaptcha.Class.php' );
require_once( CLASSES . 'mail.Class.php' );

$core  = new Core;

$cache = new Cache;

$error    = new Error;
set_error_handler( array( $error, 'parserError' ) ); //Set own error handler

$db       = new DataBase( $dbconfig );

$template = new Template;
$template->template = $board['template'];
$template->root = TEMPLATES;
$template->compile = COMPILED;
$template->checkData();

$user     = new User;
$session  = $user->initialize();

$language = new Language;

$page     = new Page;

$plugin   = new PluginManager;

$recaptcha = new ReCaptcha;

$mail     = new Mail;

$actions = array( 'login', 'register', 'usercp' );
$action = '';
$req_action = $core->_GET( 'action' );
if( !isset( $req_action ) || !in_array( $req_action, $actions ) )
{
    $action = 'forumindex';
}
else
{
    $action = $req_action;
}


require_once( ACTIONS . $action . '.php' );
?>